<template>
  <div>
    <swiper>
      <swiper-item v-for="item in banners" :key="item.id">
        <a :href="item.link">
          <img :src="item.image" alt="" @load='imageLoad'/>
        </a>
      </swiper-item>
    </swiper>
  </div>
</template>

<script>
import { Swiper, SwiperItem } from "@/components/common/swiper/index";

export default {
  components: {
    Swiper,
    SwiperItem,
  },
  data() {
    return {
      isload: false
    }
  },
  props: {
      banners: {
          type: Array,
          default() {
              return []
          }
      }
  },
  methods: {
    // 使用@load监听图片的加载，发射事件出去
    imageLoad() {
      if(!this.isload) {
        this.$emit('swiperImgLoad')
        this.isload = true
      }
    }
  }
};
</script>

<style scoped>
</style>